/**
 * 
 */
package br.srv.full.postalservices.web.base;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import br.srv.full.entities.address.AddressType;
import br.srv.full.geoProcessing.entities.GPSPoint;
import br.srv.full.geoProcessing.entities.localidades.Locale;
import br.srv.full.geoProcessing.entities.map.MapInformation;
import br.srv.full.geoProcessing.entities.map.MapType;
import br.srv.full.serviceLocator.ServiceLocator;
import br.srv.full.virtual.entities.faces.FacesAction;
import br.srv.full.virtual.faces.manager.userLogin.LoginManager;
import br.srv.full.virtual.postalServices.base.PostalServices;

/**
 * @author Carlos Delfino
 * 
 */
public final class GeoManagerAddCountry extends Object {

	private final Log log = LogFactory.getLog(getClass());
	private LoginManager loginManager;

	private Locale selectedCountry;
	private Float zoom;
	private MapType mapType =MapType.Hybrid;

	/**
	 * @return the selectedCountry
	 */
	public Locale getSelectedCountry() {
		return selectedCountry;
	}

	/**
	 * @param p_selectedCountry
	 *            the selectedCountry to set
	 */
	public void setSelectedCountry(Locale p_selectedCountry) {
		log.info(p_selectedCountry);
		selectedCountry = p_selectedCountry;
	}

	public List<SelectItem> getAddressTypes() {
		PostalServices l_postal = ServiceLocator.getService(PostalServices.class);
		List<AddressType> l_types = l_postal.getAddressTypes();
		List<SelectItem> l_itens = null;
		if (l_types != null && !l_types.isEmpty()) {
			l_itens = new ArrayList<SelectItem>(l_types.size());
			for (AddressType l_addressType : l_types) {
				SelectItem l_iten = new SelectItem(l_addressType, l_addressType.getType(), l_addressType
						.getDescription());
				l_itens.add(l_iten);
			}
		}
		return l_itens;
	}

	public AddressType getAdressType() {
		return null;
	}

	public void setAddressType(AddressType p_type) {
		log.info(p_type);
	}

	/**
	 * @return the loginManager
	 */
	public LoginManager getLoginManager() {
		return loginManager;
	}

	/**
	 * @param p_loginManager
	 *            the loginManager to set
	 */
	public void setLoginManager(LoginManager p_loginManager) {
		this.loginManager = p_loginManager;
	}

	public String getMapKey() {
		return null;
	}

	public MapInformation getMapInformation() {
		return new MapInformation(new GPSPoint(-19.844439, -43.935324), getZoom(), getMapType());
	}

	/**
	 * @return
	 */
	private MapType getMapType() { 
		return mapType;
	}
	
	public void setMapType(MapType p_mapType){
		mapType = p_mapType;
	}

	public Float getZoom() {
		return zoom;
	}
	
	public void setZoom(Float p_zoom){
		zoom = p_zoom;
	}
 

	public GPSPoint point;
	private String lastMensageSaveSelectedCountry;
 
 

	/**
	 * @return the point
	 */
	public GPSPoint getPoint() {
		return point;
	}

	/**
	 * @param p_point
	 *            the point to set
	 */
	public void setPoint(GPSPoint p_point) {
		log.info(p_point);
		point = p_point;
	}

	public void setPoint(String p_point){
		log.info(p_point);
	}
	
	public String getLastMensageSaveSelectedCountry(){
		return lastMensageSaveSelectedCountry;
	}
	
	public FacesAction saveSelectedCountry(){
		log.info("saveSelectedCountry");
		return null;
	}
}
